package arithmetic2.day08;

import java.util.Arrays;
import java.util.Comparator;

/*
    使用贪心策略求解字符串数组中所有元素结合起来之后最小的字典序序列
 */
public class Greed02 {
    public static class ComparableStr implements Comparator<String>{
        @Override
        public int compare(String o1, String o2) {
            return (o1+o2).compareTo(o2+o1);
        }
    }
    public static void main(String[] args) {
        String strs[] = {"abc","a","d","bd"};
        Arrays.sort(strs,new ComparableStr());
        for(String str:strs){
            System.out.println(str);
        }
    }
}
